package com.mhc.suzuki.constant;

/**
 * 实体类型枚举类
 * Created by kanon on 2017/8/29.
 */
public enum EntityTypeEnum {

    //订单
    ORDER(0, "order", "订单"),
    OTHER(1, "other", "其他");

    private Integer code;
    private String clazz;
    private String name;

    EntityTypeEnum(Integer code, String clazz, String name){
        this.code = code;
        this.clazz = clazz;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getClazz() {
        return clazz;
    }

    /**
     * 根据类型值获取相应的枚举类
     *
     * @param clazz
     * @return
     */
    public static Integer getCodeByClazz(String clazz) {
        for (EntityTypeEnum c : EntityTypeEnum.values()) {
            if (c.clazz.equals(clazz)) {
                return c.getCode();
            }
        }

        return null;
    }

    public static String getNamwByCode(Integer code) {
        for (EntityTypeEnum c : EntityTypeEnum.values()) {
            if (c.code.equals(code)) {
                return c.getName();
            }
        }

        return null;
    }


}
